<!-- 多个海报集成 -->
<template>
	<view style="overflow: hidden;" class="vwh df-yc">
		<!-- 导航栏 -->
		<view class="head_box w100" :style="{ background: bgcolor }">
			<cu-custom type="poster" :isBack="true" :showBackIcon="true">
				<block slot="backText">
					<text class="nav-title shopro-selector-rect">生成分享海报</text>
				</block>
			</cu-custom>
		</view>
		<view class="wh100">
			<scroll-view scroll-y="true">
				<sh-invite-poster v-if="posterType === 'user'" :goodsId="goodsId" @getShareInfo="getShareInfo">
				</sh-invite-poster>
				<sh-goods-poster v-if="posterType === 'goods'" :goodsId="goodsId" @getShareInfo="getShareInfo">
				</sh-goods-poster>
				<sh-groupon-poster v-if="posterType === 'groupon'" :goodsId="goodsId" @getShareInfo="getShareInfo">
				</sh-groupon-poster>
				<shSealPoster v-if="posterType === 'seal'"></shSealPoster>
				<shAlphaPoster v-if="posterType === 'alpha'" :inviteCode="inviteCode"></shAlphaPoster>
				<shBoxPoster v-if="posterType === 'box'" :scanData="scanData"></shBoxPoster>
				<shPotPoster v-if="posterType === 'pot'" :scanData="scanData"></shPotPoster>
				<!-- 登录提示 -->
				<shopro-login-modal></shopro-login-modal>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import shInvitePoster from './children/sh-invite-poster.vue';
	import shGoodsPoster from './children/sh-goods-poster.vue';
	import shGrouponPoster from './children/sh-groupon-poster.vue';
	import shSealPoster from './children/sh-seal-poster.vue'
	import shAlphaPoster from './children/sh-alpha-poster.vue'
	import shBoxPoster from './children/sh-box-poster.vue';
	import shPotPoster from './children/sh-pot-poster.vue'
	export default {
		components: {
			shInvitePoster,
			shGoodsPoster,
			shGrouponPoster,
			shSealPoster,
			shAlphaPoster,
			shBoxPoster,
			shPotPoster
		},
		data() {
			return {
				bgcolor: '#F0F0F0',
				posterType: '',
				CustomBar: this.CustomBar,
				goodsId: 0,
				inviteCode: "",
				daygame_stage: 1,
				team_id: 1,
				scanData: {},
				path: '',
				shareType: ''
			};
		},
		computed: {
			defaultShareInfo() {
				return uni.getStorageSync('shareInfo')
			}
		},
		onUnload() {

		},
		onHide() {

		},
		onShow() {

		},
		onLoad() {
			this.posterType = this.$Route.query.posterType
			this.shareType = this.$Route.query.shareType
			this.goodsId = this.$Route.query.id;
			this.$store.commit('updateOnPosterStatus', 0)
			if (this.$Route.query.inviteCode) {
				this.inviteCode = this.$Route.query.inviteCode
			}
			if (this.$Route.query.posterType == 'team') {
				this.daygame_stage = this.$Route.query.daygame_stage
				this.team_id = this.$Route.query.team_id
			}
			if (this.$Route.query.posterType == 'seal' || this.$Route.query.posterType == 'alpha') {
				this.setShareInfo({
					query: {
						s: uni.getStorageSync('userInfo').id
					},
					path: '/pages/index/index',
					title:uni.getStorageSync('userInfo').nickname+'邀您加入茶能成事'
				});
			}
			if (this.$Route.query.posterType == 'goods') {
				this.setShareInfo({
					query: {
						id: this.$Route.query.id
					},
					path: '/pages/goods/detail/index',
					title: '我分享了' + decodeURIComponent(this.$Route.query.title),
					image: decodeURIComponent(this.$Route.query.image)
				});
			}
			if (this.$Route.query.posterType == 'box' || this.$Route.query.posterType == 'pot') {
				this.scanData = JSON.parse(this.$Route.query.scanData)
				console.log(this.scanData)
				this.setShareInfo({
					query: {
						id: this.scanData.pro_id
					},
					path: '/pages/goods/detail/index',
					title: '我分享了' + this.scanData.pro_name,
					image: decodeURIComponent(decodeURIComponent(this.scanData.open_teabox_img))
				})
			}
			if (this.$Route.query.shareType == 'node_game') {
				this.setShareInfo({
					title: '邀你参加成事节点赛',
					path: '/pages/index/nodegame',
					query: {

					}
				});
			}
			if (this.$Route.query.shareType == 'day_game') {
				this.setShareInfo({
					title: '邀你参加竞速赛',
					path: '/pages/public/day-game/day-game',
					query: {

					}
				});
			}
			switch (this.$Route.query.posterType) {
				case 'user':
					uni.setNavigationBarTitle({
						title: '邀请好友'
					});
					break;
				case 'goods':
					uni.setNavigationBarTitle({
						title: '商品海报'
					});
					break;
				case 'groupon':
					uni.setNavigationBarTitle({
						title: '拼团海报'
					});
					break;
				default:
					uni.setNavigationBarTitle({
						title: '海报'
					});
			}
		},
		methods: {
			getShareInfo(e) {
				console.log(e);
			},
		}
	};
</script>

<style lang="scss">
	scroll-view {
		height: 100%;
	}
</style>
